<?php
require 'TVB/pms/pdes/common/bootstrap.php';

empty($_REQUEST['type']) && exit('error');

getList();

/**
 *
 */
function getList()
{
	isset($_REQUEST['type']) &&	$type =	trim($_REQUEST['type']);
	$page = isset($_REQUEST['page']) ? trim($_REQUEST['page']) : 1;
    $length = isset($_REQUEST['rows']) ? trim($_REQUEST['rows']) : 10;
	$field = isset($_REQUEST['searchField']) ? $_REQUEST['searchField'] : array();
	$oper = isset($_REQUEST['searchOper']) ? $_REQUEST['searchOper'] : array();
	$value = isset($_REQUEST['searchString']) ? $_REQUEST['searchString'] : array();
	$sidx = isset($_REQUEST['sidx']) ? trim($_REQUEST['sidx']) : NULL;
    $sord = isset($_REQUEST['sord']) ? trim($_REQUEST['sord']) : NULL;
    $unpublish = isset($_REQUEST['unpublish']) ? trim($_REQUEST['unpublish']) : NULL;

    if ($page < 1) {
        $page =	1;
    }

	$start = ($page -1) * $length;

	$findRelation =	Model::parseFindRelation($type);

    $list =	new mis_log; 
    $ret = $list->getResultList($findRelation, $field, $oper, $value, $start, $length, $sidx, $sord);
    empty($ret) && $ret = array();
	echo json_encode($ret);
}
?>
